<template>
  <div class="checkbox">
    <img :src="value ? src[1] : src[0]" @click="handleClick" />
  </div>
</template>

<script>
  export default {
    name: 'XCheckbox',
    props: {
      value: {
        type: Boolean,
        default: false,
      },
    },
    data() {
      return {
        src: ['/images/checkbox.svg', '/images/checkbox-checked.svg'],
        checked: this.value,
      }
    },
    methods: {
      handleClick() {
        this.checked = !this.checked
        this.$emit('input', this.checked)
      },
    },
  }
</script>

<style lang="scss" scoped></style>
